<extend name="Public/base" />

<block name="body">
    <div class="form-item">
                <label class="item-label">会员电话</label>
                <div class="controls">
                     <input type="text" class="text input-large" name="user_tel" id="tel">
                     <button class="btn" id="get">获取</button>
                </div>
    </div>    
    <br>
    <br>
    <br>
    <div id="content">
        <div id="tree" class="demo"></div>
    </div>
</block>
<block name="script">
    <script>
        $('#get').click(function () {
            $.post("{:U('Member/echo_data')}",{'tel':$('#tel').val()},function (data) {
                if (data.reg == 2) {
                    alert(data.info);
                } else {
                    tree();
                }
            });
        });
        function tree ()
        {
            var div = "<div id='tree' class='demo'></div>";
            $('#content').html('');
            $('#content').html(div);
            $('#tree').jstree({
                'core' : {
                    'data' : {
                        "url" : "{:U('Member/echo_data')}",
                        "dataType" : "json",
                        "data" : function (node) {
                            return { "id" : node.id };
                        }
                    }
                },
                'plugins' : ['contextmenu'],
                'contextmenu':{
                    'items':{
                        "create":null,
                        "rename":null,
                        "remove":null,
                        "ccp":null,
                        '1':{
                            'label':'健康档案',
                            'action':function (data) {
                                var inst = jQuery.jstree.reference(data.reference),
                                        obj = inst.get_node(data.reference);
                                window.open("{:U('Member/healthy_add')}"+'&id='+obj.id);
                            }
                        },
                        '2':{
                            'label':'积分动态',
                            'action':function (data) {
                                var inst = jQuery.jstree.reference(data.reference),
                                        obj = inst.get_node(data.reference);
                                window.open("{:U('Member/integral_change')}"+'&sear_val='+obj.id+'&type=recom');
                            }
                        },
                        '3':{
                            'label':'再消费',
                            'action':function (data) {
                                //alert('再消费');return;
                                var inst = jQuery.jstree.reference(data.reference),
                                        obj = inst.get_node(data.reference);
                                window.open("{:U('Member/consumption')}"+'&id='+obj.id+'&type=recom');
                            }
                        }
                    }
                }
            });
        }
    </script>
</block>
